﻿using System;
using System.Collections.Generic;
using System.Text;

namespace XmlTest
{
    public class Fire
    {
        public void CreateProto()
        {
            ;//ProtoInterface
            ProtoInterface pi = new ProtoInterface();
            field f1 = new field("position", "SFVec3f", "inputOutput");
            pi.addChildren(f1);
            //ProtoBody add group
            ProtoBody pb = new ProtoBody();
            ProtoDeclare pd = new ProtoDeclare(pb, pi);
            Group g = new Group();
            pb.addChildren(g);

            Transform t = new Transform();
            Script s = new Script();
            g.addChildren(t);
            g.addChildren(s);

            t.DEF = "t1";
            //transform add <IS/><Shape/>
            IS is_tp = new IS();
            connect c_tp = new connect("translation", "postion");
            is_tp.addChildren(c_tp);
            t.addChildren(is_tp);

            Shape shape = new Shape();
            Material m = new Material("1 0 0");
            Sphere sphere = new Sphere("2.0");
            Appearance app = new Appearance(m);
            shape.appearance = app;
            shape.gemeotry = sphere;
            t.addChildren(shape);
            //Script add <field/><![CDATA[javascript:]]>
            s.DEF = "s1";
            s.directOutput = "true";
            field f2 = new field("trans", "SFVec3f", "inputOutput");
            s.addChildren(f2);
            Scene scene = new Scene();
            Tree tree = new Tree();
            tree.Transform = new Transform("Tree");
            scene.addChildren("<!-- tree -->\n");
            scene.addChildren(X3DString.toString(pd));
            scene.addChildren(tree);
            scene.addChildren("<!-- tree -->\n");
            System.Windows.Forms.MessageBox.Show(X3DString.toString(scene ));
        }
    }
}
